<form action="" id="catEditor" method="post" target="">
  <div class="gridlist-action">
    <{button label="添加门店" app="desktop" onclick="new Dialog('index.php?app=o2o&ctl=admin_store&act=add',{width:650,height:650,title:'添加门店'})" icon="btn_add.gif" }>
    &nbsp;<button type="button" class="btn" onclick="javascript:window.open('index.php?app=o2o&ctl=admin_store&act=exportTemplate&finder_id=<{$env.get.finder_id}>')" id="btn_new_member"><span><span>导出模板</span></span></button>
    &nbsp;<button type="button" class="btn" onclick="new Dialog('index.php?app=o2o&ctl=admin_store&act=import&finder_id=<{$env.get.finder_id}>',{width:400,height:150,title:'批量导入门店'})" id="btn_new_member"><span><span>导入门店</span></span></button>
  </div>
  <table cellspacing="0" cellpadding="0" class="gridlist">
    <col class="Colauto"></col>
    <col class="Coloption_1b"></col>
    <thead>
      <th><{t}>组织名称<{/t}></th>
      <th><{t}>操作<{/t}></th>

    </thead>
    <tbody>
      <{foreach from=$organization item=item key=iLoop name="item"}>
      <tr parentid="<{$item.org_id}>" class="provice-bg">
        <td style="text-align:left; width:320px;">
          <div style="padding-left:<{$item.step*25}>px">
            <{if $item.child_count>0}>
            <span class="imgTree" onclick="clickTree(this);" id="<{$item.org_id}>"> &nbsp;&nbsp; </span>
            <{else}>
            <span class="imgTree tree_open"> &nbsp;&nbsp; </span>
            <{/if}>
            <span style="font-weight:700; color:#000; text-decoration:none;padding-right:15px;" ><{$item.org_name}></span>
          </div>
        </td>
        <td style="width:350px">
            <{if $item.org_type == 1}>
                <a class="i" href='index.php?app=o2o&ctl=admin_store&act=add&p[0]=&p[1]=<{$item.org_id}>' target="dialog::{title:'<{t}>新增门店<{/t}>',width:650,height:650}">新增</a>
            <{elseif $item.org_type == 2}>
                <a class="i" href='index.php?app=o2o&ctl=admin_store&act=edit&p[0]=<{$item.org_id}>' target="dialog::{title:'<{t}>编辑门店<{/t}>',width:650,height:650}">编辑</a>
                &nbsp;|&nbsp;<a href="javascript:if(confirm('确认删除门店&nbsp;[<{$item.org_name|replace:'\'':'\\\''}>]&nbsp;？')){W.page('index.php?app=o2o&ctl=admin_store&act=toRemoveStore&p[0]=<{$item.org_id}>', {method:'get'})}void(0);" target="">删除
            <{/if}>
        </td>
      </tr>
      <{/foreach}>
    </tbody>
  </table>
</form>

<script>
function clickTree(el){
    var el=$(el), obj = el.getParent('[parentid]');
    if(!el.hasClass("tree_open")){
        if(!obj.getNext() || !obj.getNext().get('readstatus')){
            var tr=new Element('tr[readstatus=1]').injectAfter(obj).setHTML('<td colspan="5" style="border:0;padding:0;"></td>');
            W.page('index.php?app=o2o&ctl=admin_store&act=getChildNode',{update:tr.firstChild,method:'post',data:'orgId='+el.id});
        }
        obj.getNext().show();
        el.addClass("tree_open");
    }else{
        obj.getNext().hide();
        el.removeClass("tree_open");
    }
}
</script>
